cmake_minimum_required(VERSION 3.0.2)

SET(CMAKE_BUILD_TYPE Release)

project(tecbot)

SET(${BOOST_PATHS} "/usr/lib/boost")

find_package(Boost 1.80.0 COMPONENTS REQUIRED ALL PATHS ${BOOST_PATHS})

if(Boost_FOUND)
	message(STATUS "Boost Library:" ${Boost_LIBRARIES})
	message(STATUS "Version:" ${Boost_VERSION})
	message(STATUS "Libraries:" ${Boost_LIBRARIES})
	message(STATUS "Include Path:" ${Boost_INCLUDE_DIRS})
else()
	message(FATAL_ERROR "Error! Boost not found!")
endif()

find_package(catkin REQUIRED COMPONENTS
	cartographer_ros_msgs
	roslaunch
	geometry_msgs
	nav_msgs
	roscpp
	rospy
	sensor_msgs
	costmap_2d
	tf
	urdf
	message_generation
	std_msgs
	genmsg
	actionlib_msgs
	actionlib
	pcl_ros
	laser_geometry
	tf2
	tf2_ros
	tf2_sensor_msgs
	tecbot_msgs
	serial
)

find_package(Eigen3 REQUIRED)
find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)

include_directories(
	include
	${PCL_INCLUDE_DIRS}
	${EIGEN3_INCLUDE_DIR}
	${catkin_INCLUDE_DIRS}
)

catkin_package(
	CATKIN_DEPENDS roscpp std_msgs message_runtime rospy costmap_2d tf2 tf2_ros tf2_sensor_msgs
	DEPENDS EIGEN3 PCL OpenCV
	INCLUDE_DIRS
)

# driver
add_executable(chassis_handler
	src/driver/chassis_handler.cpp)

target_link_libraries(chassis_handler
	${catkin_LIBRARIES}
	${Boost_LIBRARIES}
)

add_executable(screen_handler
	src/driver/screen_handler.cpp)

target_link_libraries(screen_handler
	${catkin_LIBRARIES}
	${Boost_LIBRARIES}
)

add_executable(simulation_handler
	src/driver/simulation_handler.cpp)

target_link_libraries(simulation_handler
	${catkin_LIBRARIES}
	${Boost_LIBRARIES}
)

# teleop
add_executable(teleop_handler
	src/teleop/teleop_handler.cpp
)

target_link_libraries(teleop_handler
	${catkin_LIBRARIES}
)

# localization
add_executable(localization_handler
	src/localization/localization_handler.cpp
)

target_link_libraries(localization_handler
	${catkin_LIBRARIES}
)

# navigation
add_library(controllers
	src/navigation/utils/controllers.cpp
)

add_library(mover
	src/navigation/utils/local_planner/mover.cpp
)

target_link_libraries(mover
	controllers
	${catkin_LIBRARIES}
)

add_library(path_follower
	src/navigation/utils/local_planner/path_follower.cpp
)

target_link_libraries(path_follower
	controllers
	mover
	${catkin_LIBRARIES}
)

add_library(global_planner
	src/navigation/utils/global_planner/quadratic_calculator.cpp
	src/navigation/utils/global_planner/dijkstra.cpp
	src/navigation/utils/global_planner/grid_path.cpp
	src/navigation/utils/global_planner/gradient_path.cpp
	src/navigation/utils/global_planner/orientation_filter.cpp
	src/navigation/utils/global_planner/planner.cpp
)

add_executable(global_planner_handler
	src/navigation/global_planner/global_planner_handler.cpp
)

target_link_libraries(global_planner_handler
	global_planner
	${catkin_LIBRARIES}
)

add_executable(navigation_handler
	src/navigation/navigation/navigation_handler.cpp
)

target_link_libraries(navigation_handler
	controllers
	path_follower
	mover
	${catkin_LIBRARIES}
)

add_executable(obstacle_handler
	src/navigation/obstacle/obstacle_handler.cpp
)

target_link_libraries(obstacle_handler
	${catkin_LIBRARIES}
)